import { defHttp } from "@/utils/http";

// ERP 对象 VO
export interface ObjectVO {
	objId: number; // 对象ID
	objNo: string; // 对象代码
	objName: string; // 对象名称
	sourceId: string; // 来源
	objType: number; // 对象类型
	grpNo: string; // 分组代码
	whsNo: string; // 仓库代码
	hideFlag: number; // 隐藏标志
	objRatio: number; // 对象比例
}

// ERP 对象 API
export const ObjectApi = {
	// 查询对象分页
	getObjectPage: async (params: any) => {
		return await defHttp.get({ url: `/whs/obj-info/page`, params });
	},

	// 查询对象详情
	getObject: async (id: number) => {
		return await defHttp.get({ url: `/whs/obj-info/get?id=` + id });
	},

	// 新增对象
	createObject: async (data: ObjectVO) => {
		return await defHttp.post({ url: `/whs/obj-info/create`, data });
	},

	// 修改对象
	updateObject: async (data: ObjectVO) => {
		return await defHttp.put({ url: `/whs/obj-info/update`, data });
	},

	// 删除对象
	deleteObject: async (id: number) => {
		return await defHttp.delete({ url: `/whs/obj-info/delete?id=` + id });
	},

	// 导出对象 Excel
	exportObject: async (params: any) => {
		return await defHttp.download({ url: `/whs/obj-info/export-excel`, params });
	}
};
